Add tests
authorjustbur <justin@burkett.cc>
Tue, 5 Apr 2016 14:04:54 +0000 (10:04 -0400)
committerjustbur <justin@burkett.cc>
Tue, 5 Apr 2016 14:04:54 +0000 (10:04 -0400)
which-key-tests.el [new file with mode: 0644]

diff --git a/which-key-tests.el b/which-key-tests.el
new file mode 100644 (file)
index 0000000..e5c8c4a
--- /dev/null
@@ -0,0 +1,57 @@
+;;; which-key-tests.el --- Tests for which-key.el -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015 Justin Burkett
+
+;; Author: Justin Burkett <justin@burkett.cc>
+;; URL: https://github.com/justbur/emacs-which-key
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests for which-key.el
+
+;;; Code:
+
+(require 'which-key)
+(require 'ert)
+
+(ert-deftest which-key-test-prefix-declaration ()
+  "Test `which-key-declare-prefixes' and
+`which-key-declare-prefixes-for-mode'. See Bug #109."
+  (let* (test-mode which-key-prefix-name-alist which-key-prefix-title-alist)
+    (which-key-declare-prefixes
+      "SPC C-c" '("complete" . "complete title")
+      "SPC C-k" "cancel")
+    (which-key-declare-prefixes-for-mode 'test-mode
+      "C-c C-c" '("complete" . "complete title")
+      "C-c C-k" "cancel")
+    (should (equal
+             (assoc-string "SPC C-k" which-key-prefix-name-alist)
+             '("SPC C-k" . "cancel")))
+    (should (equal
+             (assoc-string
+              "C-c C-c" (cdr (assq 'test-mode which-key-prefix-name-alist)))
+             '("C-c C-c" . "complete")))
+    (pp which-key-prefix-title-alist)
+    (should (equal
+             (assoc-string "SPC C-k" which-key-prefix-title-alist)
+             '("SPC C-k" . "cancel")))
+    (should (equal
+             (assoc-string
+              "C-c C-c" (cdr (assq 'test-mode which-key-prefix-title-alist)))
+             '("C-c C-c" . "complete title")))))
+
+(provide 'which-key-tests)
+;;; which-key-tests.el ends here